Shader "HolaShader/HalfLambertFragShader"
{
    Properties
    {
        _Diffuse("Diffuse Color", Color) = (1,1,1,1)
    }
    SubShader
    {
        Tags { "LightMode" = "ForwardBase" }

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "Lighting.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
                fixed3 worldNormal : TEXCOORD0;
            };

            fixed4 _Diffuse;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.worldNormal = mul(v.normal, (float3x3)unity_WorldToObject);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
               fixed3 ambient = normalize(UNITY_LIGHTMODEL_AMBIENT.xyz);
                fixed3 worldNormalDir = normalize(i.worldNormal);
                fixed3 lightDir = normalize(_WorldSpaceLightPos0.xyz);

                fixed3 diffuse = _LightColor0.rgb * _Diffuse.rgb * saturate(dot(lightDir, worldNormalDir) * 0.5 + 0.5);
                fixed3 color = ambient + diffuse;
                return fixed4(color.rgb, 1.0);
            }
            ENDCG
        }
    }
    Fallback "Diffuse"
}
